package cc.co.cutenimy.nimyexplore.ui.widget;

import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.widgets.Composite;

/**
 * Create some composite and help to create common composite.
 * 
 * @author 234aini@gmail.com
 * 
 */
public class WidgetGenerator {
	public static final WidgetGenerator INS = new WidgetGenerator();

	private WidgetGenerator() {

	}

	public static WidgetGenerator get() {
		return INS;
	}

	/**
	 * Simple way to generate a composite with grid layout.
	 * 
	 * @param parent
	 * @param column
	 * @param style
	 * @return
	 */
	public Composite gridComposite(final Composite parent, int column, int style) {
		Composite composite = new Composite(parent, style);
		GridLayoutFactory.fillDefaults().numColumns(column).applyTo(composite);
		return composite;
	}

	/**
	 * Set the composite with the Grid layout and set it column number.
	 * 
	 * @param composite
	 * @param column
	 * @return
	 */
	public Composite grid(final Composite composite, int column) {
		GridLayoutFactory.fillDefaults().numColumns(column).applyTo(composite);
		return composite;
	}
}
